package com.dd.shop4j.console.system.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dd.shop4j.common.utils.Page;
import com.dd.shop4j.sys.mapper.SysConstantMapper;
import com.dd.shop4j.sys.model.SysConstant;

/**
 * 系统管理业务类
 * @ClassName: SystemManagerService
 * @Description: TODO
 * @author 唐小恕
 * @date 2013年12月17日 下午12:27:37
 *
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class SystemManagerService {

	@Resource
	private SysConstantMapper sysConstantMapper;
	
	/**
	 * 分页查询系统参数
	 * @param constant
	 * @param curpage
	 * @param pagesize
	 * @return
	 */
	public Page<SysConstant> queryConstantByPage(SysConstant constant, int curpage, int pagesize) {
		List<SysConstant> constants = sysConstantMapper.queryPageBySelective(constant, (curpage - 1) * pagesize, pagesize, null, null);
		int count = sysConstantMapper.getCountBySelective(constant);
		return new Page<SysConstant>(constants, count, curpage, pagesize);
	}
	
	/**
	 * 修改系统参数信息
	 * @param constant
	 * @return
	 */
	public int updateConstant(SysConstant constant) {
		return sysConstantMapper.updateSelectiveByPrimaryKey(constant);
	}
	
}
